import React from 'react';
import {createAppContainer} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
import {createBottomTabNavigator} from 'react-navigation-tabs';
import MCIcons from 'react-native-vector-icons/MaterialCommunityIcons';
import Ionicons from 'react-native-vector-icons/Ionicons';
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
import Entypo from 'react-native-vector-icons/Entypo';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import Storage from '../deviceStorage';
import Login from '../views/login/Login';
import AlarmOverview from '../views/alarmOverview/AlarmOverview';
import HistoryAlarm from '../views/historicalAlarm/HistoryAlarm';
import Order from '../views/order/Order';
import Workstation from '../views/workstation/Workstation';
import SetUp from '../views/setUp/SetUp';
import Overlay from '../views/overlay/Overlay';
// Storage.get('jurisdiction').then(obj => {
//   const jurisdictionList = JSON.parse(obj);
//   const tempJurisdictionKeysEn = jurisdictionList.map(item => {
//     return item.en_name;
//   });
//   const getKeys = Object.keys(RouteConfigs);
//   getKeys.forEach(item => {
//     if (!tempJurisdictionKeysEn.include(item)) {
//       delete RouteConfigs[item];
//     }
//   });
// });

// 底部路由开始
let RouteConfigs = {
  // 报警概览
  AlarmOverviewScreen: {
    screen: AlarmOverview,
    path: '/alarmOverview',
    navigationOptions: ({navigation}) => ({
      title: `报警概览`,
      tabBarIcon: ({tintColor, focused}) => (
        <MCIcons name={'alarm-bell'} size={24} color={tintColor}/>
      ),
    }),
  },
  // 历史报警
  HistoryAlarm: {
    screen: HistoryAlarm,
    path: '/historyAlarm',
    navigationOptions: ({navigation}) => ({
      title: `历史报警`,
      tabBarIcon: ({tintColor, focused}) => (
        <Ionicons name={'md-list-box'} size={24} color={tintColor}/>
      ),
    }),
  },
  // 订单
  Order: {
    screen: Order,
    path: '/order',
    navigationOptions: ({navigation}) => ({
      title: `订单`,
      tabBarIcon: ({tintColor, focused}) => (
        <FontAwesome5 name={'jedi-order'} size={24} color={tintColor}/>
      ),
    }),
  },
  // 工作站
  Workstation: {
    screen: Workstation,
    path: '/workstation',
    navigationOptions: ({navigation}) => ({
      title: `工作站`,
      tabBarIcon: ({tintColor, focused}) => (
        <Entypo name={'network'} size={24} color={tintColor}/>
      ),
    }),
  },
  // 参数设置
  SetUp: {
    screen: SetUp,
    path: '/setUp',
    navigationOptions: ({navigation}) => ({
      title: `参数设置`,
      tabBarIcon: ({tintColor, focused}) => (
        <MaterialIcons name={'perm-data-setting'} size={24} color={tintColor}/>
      ),
    }),
  },
};

const BottomTabNavigatorConfig = {
  tabBarOptions: {
    activeTintColor: '#5DD5C8',
    showIcon: true,
  },
};
const bottomTabNavigator = createBottomTabNavigator(RouteConfigs, BottomTabNavigatorConfig);
// 底部路由结束

// 页面导航开始 包含login
const AppNavigator = createStackNavigator({
  Overlay: {screen: Overlay},
  Login: {screen: Login},
  Main: {screen: bottomTabNavigator},
}, {
  // initialRouteName:'Login',
  initialRouteName: 'Overlay',
  navigationOptions: {},
  headerMode: 'none',
});
// 页面导航结束  包含login


export default createAppContainer(AppNavigator);
